<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        function fun1() {
            console.log("无参方法fun1()被调用");
        }

        //函数调用才会生效
        fun1();

        function fun2(a, b) {
            console.log("有参方法fun2(a, b)被调用，a = " + a + ", b = " + b)
        }

        //参数个数不对也可以传入,少了的参数值 = undefined
        fun2(1);
        fun2(100, 200, 300);

        //JS中没有重载机制，后来的同名方法会把前面的同名方法覆盖
        function fun3(a) {
            console.log("有参方法fun3(a)被调用，a = " + a)
        }

        function fun3(a, b, c) {
            console.log("有参方法fun3(a, b, c)被调用，a = " + a + ", b = " + b + ", c = " + c)
        }

        //有参方法fun3(a, b, c)被调用，a = 1, b = undefined, c = undefined
        //有参方法fun3(a, b, c)被调用，a = 1, b = 2, c = 3
        fun3(1);
        fun3(1, 2, 3);

        function sum(a, b) {
            return a + b;
        }

        console.log(sum(10, 30));

        function fun4() {
            console.log(arguments.length);
            for (var i = 0; i < arguments.length; i++) {
                console.log(arguments[i]);
            }
        }

        fun4(1, 2, 3, 4, 5);
    </script>
</head>
<body>

</body>
</html>